﻿var CalendarTodo = function (rHd) {
    var __hd = (typeof (rHd) == "string") ? rHd : "calendarTodo";
    //data:TodoKey,StartToPlan,IfAssigned,Title,Level,IfClose,CellKey
    var __data = null;
    var __content = null;
    var __linkCss = null;
    var __str = null;
    var __cell = null;
    var __item = null;
    var __ITEM = function () {
        this.TodoKey = null;
        this.StartToPlan = null;
        this.AssignedFlg = null;
        this.Title = null;
        this.Level = null;
        this.IfClose = null;
        this.CellKey = null;
    };
    var __parseTodo = function (rTodo) {
        __item.TodoKey = rTodo[0];
        __item.StartToPlan = rTodo[1];
        __item.AssignedFlg = parseInt(rTodo[2]);
        __item.Title = rTodo[3];
        __item.Level = rTodo[4];
        __item.IfClose = (rTodo[5] == 1) ? true : false;
        __item.CellKey = rTodo[6];
    };
    this.load = function (v) {
        __data = v;
    };
    this.display = function () {
        __item = new __ITEM();
        for (var i = 0; i < __data.length; i++) {
            __parseTodo(__data[i]);
            __str = '<div class="todo_item">';
            if (__item.AssignedFlg==2) {
                __str += '<font class="assOut">' + __item.StartToPlan + '</font> ';
            } else if (__item.AssignedFlg == 1) {
                __str += '<font class="assIn">' + __item.StartToPlan + '</font> ';
            } else if (__item.Level == "todolevel_important") {
                __str += '<font class="impo">' + __item.StartToPlan + '</font> ';
            } else {
                __str += '<font class="dt">' + __item.StartToPlan + '</font> ';
            }
            __linkCss = (__item.IfClose == 1) ? "close" : "link";
            __str += '<a href="Admin/Calendar/TodoView.aspx?id=' + __item.TodoKey + '" class="' + __linkCss + '">' + __item.Title + '</a>';
            __str += '</div>';
            __cell = $("#" + __item.CellKey);
            if (__cell != null) {
                __cell.innerHTML += __str;
            }
            __cell = null;
            __str = null;
        }
        __item = null;
    };
};